﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web.UI;

namespace JQuery.Net
{
    public enum JQNDataTypes
    {
        /// <summary>
        /// is a XML document that can be processed via jQuery
        /// </summary>
        xml,
        /// <summary>
        /// is HTML as plain text; included script tags are evaluated when inserted in the DOM.
        /// </summary>
        html,
        /// <summary>
        /// Evaluates the response as JavaScript and returns it as plain text. Disables caching unless option "cache" is used. Note: This will turn POSTs into GETs for remote-domain requests.
        /// </summary>
        script,
        /// <summary>
        /// Evaluates the response as JSON and returns a JavaScript object. In jQuery 1.4 the JSON data is parsed in a strict manner; any malformed JSON is rejected and a parse error is thrown. (See json.org for more information on proper JSON formatting.)
        /// </summary>
        json,
        /// <summary>
        /// Loads in a JSON block using JSONP. Will add an extra "?callback=?" to the end of your URL to specify the callback. 
        /// </summary>
        jsonp, 
        /// <summary>
        /// A plain text string.
        /// </summary>
        text

    }

    public enum JQNRequestType
    {
        GET,
        POST,
        PUT,
        DELETE
    }

    [
    TypeConverter(typeof(ExpandableObjectConverter))
    ]
    public class AjaxConfig
    {
        #region ajax settings - properties
        /// <summary>
        /// The content type sent in the request header that tells the server what kind of response it will accept in return. If the accepts setting needs modification, it is recommended to do so once in the $.ajaxSetup() method
        /// </summary>
        //public string Accepts { get; set; }
        /// <summary>
        /// A password to be used in response to an HTTP access authentication request.
        /// </summary>
        public string Password { get; set; }
        /// <summary>
        /// A username to be used in response to an HTTP access authentication request.
        /// </summary>
        public string UserName { get; set; }
        /// <summary>
        /// A string containing the URL to which the request is sent.
        /// </summary>
        public string Url { get; set; }
        [
        Category("Behavior"),
        DefaultValue("json"),
        Description("possible values: xml, html, script, json, jsonp, text"),
        NotifyParentProperty(true)
        ]
        public JQNDataTypes? DataTypes { get; set; }
        /// <summary>
        /// The type of request to make ("POST" or "GET"), default is "GET". Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they are not supported by all browsers.
        /// </summary>
        [
        Category("Behavior"),
        DefaultValue("GET"),
        Description("default is 'GET'. Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they are not supported by all browsers."),
        NotifyParentProperty(true)
        ]
        public JQNRequestType? RequestType { get; set; }
        /// <summary>
        /// By default, all requests are sent asynchronously (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active.
        /// </summary>
        [
        Category("Behavior"),
        DefaultValue(true),
        Description("If you need synchronous requests, set this option to false."),
        NotifyParentProperty(true)
        ]
        public bool? Async { get; set; }
        /// <summary>
        /// Default: true, false for dataType 'script' and 'jsonp'
        /// If set to false, it will force requested pages not to be cached by the browser.
        /// </summary>
        [
        Category("Behavior"),
        DefaultValue(true),
        Description("If set to false, it will force requested pages not to be cached by the browser."),
        NotifyParentProperty(true)
        ]
        public bool? Cache { get; set; }
        public bool? CrossDomain { get; set; }
        public bool? Global { get; set; }
        public bool? IfModified { get; set; }
        #endregion
    }
}
